﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Form09
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_MouseEnter(object sender, EventArgs e)
        {
            int x = this.ClientSize.Width - label1.Width;
            int y = this.ClientSize.Height - label1.Height;
            Random r = new Random();  //产生随机数   
            label1.Location = new Point(r.Next(0,x+1),r.Next(0,y+1)); 

            //label1.Left = r.Next(0,this.Width-label1.Width-5);
            ////返回一个指定范围的随机数，并赋值给label1的top属性
            //label1.Top = r.Next(0, this.Height - label1.Height - 5);

        }

        private void label1_MouseClick(object sender, MouseEventArgs e)
        {
            MessageBox.Show("哈哈哈 被你追到了");
            //this.Close();
        }

        private void label1_Click(object sender, EventArgs e)
        {
           // MessageBox.Show("单机组件时发生");
        }
    }
}
